package site

import (
	. "go-caipu/pkg/services/sqlstore/migrator"
)

func AddUserMigrations(mg *Migrator) {
	userV1 := Table{
		Name: "tb_site_user",
		Columns: []*Column{
			{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
			{Name: "sn", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
			{Name: "username", Type: DB_Varchar, Length: 64, Nullable: false},
			{Name: "password", Type: DB_NVarchar, Length: 128, Nullable: false},
			{Name: "nick_name", Type: DB_NVarchar, Length: 128, Nullable: false},
			{Name: "phone", Type: DB_NVarchar, Length: 11, Nullable: true},
			{Name: "role_id", Type: DB_BigInt, Length: 20, Nullable: false},
			{Name: "salt", Type: DB_NVarchar, Length: 255, Nullable: false},
			{Name: "avatar", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "sex", Type: DB_NVarchar, Length: 10, Nullable: true},
			{Name: "email", Type: DB_NVarchar, Length: 128, Nullable: false},
			{Name: "dept_id", Type: DB_NVarchar, Length: 20, Nullable: false},
			{Name: "post_id", Type: DB_NVarchar, Length: 20, Nullable: false},
			{Name: "status", Type: DB_BigInt, Length: 4, Nullable: false},
			{Name: "remark", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "remark", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "last_login_ip", Type: DB_NVarchar, Length: 32, Nullable: true},
			{Name: "last_login_at", Type: DB_NVarchar, Length: 32, Nullable: true},
			{Name: "create_by", Type: DB_BigInt, Nullable: false},
			{Name: "update_by", Type: DB_BigInt, Nullable: true},
			{Name: "created_at", Type: DB_DateTime, Nullable: false},
			{Name: "updated_at", Type: DB_DateTime, Nullable: true},
			{Name: "deletedAt", Type: DB_DateTime, Nullable: true},
		},
		Indices: []*Index{
			{Cols: []string{"username"}, Type: UniqueIndex},
			{Cols: []string{"email"}, Type: UniqueIndex},
			{Cols: []string{"phone"}, Type: UniqueIndex},
		},
	}

	//create table
	mg.AddMigration("create tb_site_user table", NewAddTableMigration(userV1))
}
